package thread;
class MyRunnable implements Runnable{
//Runnable就是用来描述"要执行的任务是什么".通过Tread来创建线程,
// 线程要执行的任务是通过Runnable来描述的,而不是通过Tread自己来描述的
    @Override
    public void run() {
        while (true){
            System.out.println("hello runnable");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }

    }
}
public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        MyRunnable myRunnable=new MyRunnable();
        Thread thread=new Thread(myRunnable);
        thread.start();
        while (true){
            System.out.println("hello main");
                Thread.sleep(1000);
        }
    }
}
